<!DOCTYPE HTML>
<html>
<head>
<title>Func() | AutoHotkey</title>
<meta name="description" content="The Func function retrieves a reference to a function." />
<meta name="ahk:equiv-v2" content="objects/Func.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>Func(FunctionName) <span class="ver">[v1.1.00+]</span></h1>

<p>获取一个函数的引用.</p>

<pre class="Syntax">FunctionReference := <span class="func">Func</span>(FunctionName)</pre>
<h2 id="Parameters">参数</h2>
<dl>

  <dt>FunctionName</dt>
  <dd><p>要获取引用的函数名称. <em>FunctionName</em> 必须真实存在于脚本中.</p></dd>

</dl>

<h2 id="Return_Value">返回值</h2>
<p>函数返回对 <em>FunctionName</em> 的<a href="../Objects.htm#Function_References">函数引用</a>. 如果脚本中 <em>FunctionName</em> 不存在则返回 0. (通过 <a href="_Include.htm">#Include</a> 或非动态调用的<a href="../Functions.htm#lib">库函数</a>也属于当前脚本中的函数.)</p>

<h2 id="Remarks">备注</h2>
<p>本函数可用于调用函数或获取函数的<a href="../objects/Func.htm">信息</a>, 比如函数参数的最小和最大数目等.</p>

<h2 id="Related">相关</h2>
<p><a href="../Objects.htm#Function_References">函数引用</a>, <a href="../objects/Func.htm">Func 对象</a></p>
<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 检索一个函数的引用, 并显示其相关信息.</p>
<pre>fn := Func("StrLen")
MsgBox % fn.Name "() 是 " (fn.IsBuiltIn ? "内置函数." : "用户定义的函数.")</pre>
</div>

</body>
</html>